home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / UIFlow 1.0.1 / UIFlow Source / CFDFront / NewStuff.h < prev    next >
Encoding:
Text File  |  1992-02-21  |  20.7 KB  |  424 lines  |  [TEXT/MPS ]

  1. // *********************************************************************************
  2. //    Header File for Class definitions
  3. // *********************************************************************************
  4. // **********************************************************************
  5. //    TOutput class.
  6. // **********************************************************************
  7. class TOutput : public TObject
  8.     {
  9.     protected:
  10.         TDocument * fDocument;
  11.         Boolean    fGrid;                                                                                                // save the grid in this file?
  12.     public:
  13.         void IOutput (TDocument *,short);
  14.         virtual void Write(short, char *);
  15.         Boolean GetGrid (void)                                        {return fGrid;}                        // return fGrid value
  16.     };
  17.     
  18. // **********************************************************************
  19. //    TOutput class.
  20. // **********************************************************************
  21. class TFOutput : public TOutput
  22.     {
  23.     public:
  24.         void Write(short, char *);
  25.     };
  26.     
  27. // *********************************************************************************
  28. //    TPoint Class
  29. // *********************************************************************************
  30. class TPoint : public TObject
  31.     {
  32. // ----------------------------------------------------------------------------------------------------
  33. //    protected variables & methods
  34. // ----------------------------------------------------------------------------------------------------
  35.     protected:
  36.         Point        savePoint;                                                                                    // save the location of this object
  37.         Boolean     fIsSelected;                                                                                    // is the point selected
  38.         Boolean        fIsObstacle;                                                                                    // is point the upper left cornor of an obstacle
  39.         Rect            fFillRect, fillRect,fHoldRect;                                                            // display rectangle
  40.         float            fMag;
  41.         short        fType;                                                                                            // segment type
  42.         short        fCell;
  43. // ----------------------------------------------------------------------------------------------------
  44. //    public variables & methods
  45. // ----------------------------------------------------------------------------------------------------
  46.     public:
  47.         TObject    *    fObsUpLeft;                                                                                // the obstacle pointer
  48.         TObject    *    fObsUpRight;                                                                                // the obstacle pointer
  49.         TObject    *    fObsLwLeft;                                                                                // the obstacle pointer
  50.         TObject    *    fObsLwRight;                                                                            // the obstacle pointer
  51.         TObject    *    fBaffAbove;                                                                                // the obstacle pointer
  52.         TObject    *    fBaffBelow;                                                                                // the obstacle pointer
  53.         TObject    *    fBaffLeft;                                                                                    // the obstacle pointer
  54.         TObject    *    fBaffRight;                                                                                // the obstacle pointer
  55.         Point        fStart;                                                                                            // object location
  56.         Point        fTrans, fHTrans;
  57.         Point        fHold;
  58.         
  59.         void     IPoint (short, short,short,float);                                                            // initialization routine
  60.         Boolean OnPoint (Point *);                                                                            // is mouse on this point?
  61.         void     DrawSection (Point);                                                                            // draws the segment
  62.         void     DrawGrid(Point);                                                                                    // draws the line as grid
  63.         void     HighlightSection (Point);
  64.         void     SetStart(short, short);
  65.         void     SetHold(short, short);
  66.         void    FixHold(void);
  67.         void     DrawHoldLine(short,Point);
  68.         void  DrawTemp(Point, Point);
  69.         void     TransformPoint(float);
  70.  
  71.         Point    GetStart (void)                            {return fStart;}                                // returns fStart
  72.         Boolean    IsSelected (void)                        {return fIsSelected;}                            // returns fIsSelected
  73.         void        SetSelection (Boolean value)        {fIsSelected = value;}                        // stores fIsSelected
  74.         void        RememberPoint (void)                {savePoint = fStart;}                        // stores fStart in savePoint
  75.         Point    RetrievePoint (void)                    {return savePoint;}                            // returns savePoint
  76.         void        SetSectionType (short sType)    {fType = sType;}                                // store the segments type
  77.         short    GetSectionType (void)                {return fType;}                                    // return the segments type
  78.         void        SetCell (short cell)                    {fCell = cell;}                                    // store the starting cell
  79.         short    GetCell (void)                            {return fCell;}                                    // return the starting cell
  80.         void        SetObstacle(Boolean,short,TObject *);                                                // establish the obstacle
  81.         TObject* GetObsQuad(short);
  82.         void        SetBaffle(Boolean,short,TObject *);                                                    // establish the baffle
  83.         TObject * GetBaffQuad(short);
  84.             
  85. // ----------------------------------------------------------------------------------------------------
  86. //    Virtuals .... Override these!
  87. // ----------------------------------------------------------------------------------------------------
  88.         virtual void Highlight(void);                                                                            // highlight the point
  89.         virtual void Draw(void);                                                                                // draw the point
  90.         virtual void DrawHold(void);                                                                            // temp holding for drag
  91.         virtual Boolean IsCornor (void);                                                                    // point a cornor point?
  92.         virtual Boolean IsSegment (void);                                                                    // returns false.
  93.         virtual Boolean IsBoundryPt (void);                                                                // returns true.
  94.         virtual Boolean IsInterior (void);                                                                    // returns true.
  95.     };
  96.  
  97. // *********************************************************************************
  98. //    TGPoint Class                     =    Grid Points
  99. //        draws differently from TPoint
  100. //        these are the grid markers found on the boundries
  101. // *********************************************************************************
  102. class TGPoint : public TPoint
  103.     {
  104. // ----------------------------------------------------------------------------------------------------
  105. //    public variables & methods  :  OVERRIDING FROM TPOINT
  106. // ----------------------------------------------------------------------------------------------------
  107.     public:
  108. //    Overriding TPoint Methods    .......................................................            
  109.         void Highlight(void);                                                                                        // highlight the point
  110.         void Draw(void);                                                                                            // draw the point
  111.         void DrawHold(void);
  112. void Drawd (void);
  113.     };
  114.     
  115. // *********************************************************************************
  116. //    TGridPoint Class                 =    Grid Points
  117. //        draws differently from TPoint 
  118. //        these are the actual INTERAL grid points
  119. // *********************************************************************************
  120. class TGridPoint : public TGPoint
  121.     {
  122. // ----------------------------------------------------------------------------------------------------
  123. //    public variables & methods  :  OVERRIDING FROM TPOINT
  124. // ----------------------------------------------------------------------------------------------------
  125.     public:
  126. //    Overriding TPoint Methods    .......................................................            
  127.         Boolean IsBoundryPt(void)                        {return false;}                                // returns false
  128.         Boolean IsInterior (void)                            {return true;}                                // point IS interior
  129.     };
  130.     
  131. // *********************************************************************************
  132. //    TSegPoint Class                =    Segment Points
  133. //        contains the data for the segments
  134. //        has methods for accessing the data & drawing
  135. // *********************************************************************************
  136. class TSegPoint : public TPoint
  137.     {
  138. // ----------------------------------------------------------------------------------------------------
  139. //    protected variables & methods 
  140. // ----------------------------------------------------------------------------------------------------
  141.     protected:
  142.         WallRecord    fInitData;                                                                                    // data for this segment
  143.         short            fIsProfile[cNumProfiles];
  144.         float                fProfile[cNumProfiles][2][cMaxProfVals];
  145.         
  146. // ----------------------------------------------------------------------------------------------------
  147. //    public variables & methods 
  148. // ----------------------------------------------------------------------------------------------------
  149.     public:
  150.         void SetData (WallRecord newData);                                                                // store the segment data
  151.         WallRecord GetData (void)                                {return fInitData;}                    // return the segment data
  152.  
  153. //    Overriding TPoint Methods    .......................................................    
  154.         void IPoint(short p1V, short p1H, short type,float);                                        // initialization routine
  155.         void Highlight(void);                                                                                        // highlight the point
  156.         void Draw(void);                                                                                            // draw the point
  157.         void DrawHold(void);
  158.         Boolean IsSegment (void);                                                                                // returns true
  159.     };
  160.     
  161. // *********************************************************************************
  162. //    TCornorPoint Class            =    Cornor points of the original rectangle
  163. //        draws differently from TPoint
  164. // *********************************************************************************
  165. class TCornorPoint : public TSegPoint
  166.     {
  167.         Boolean fSeg;
  168. // ----------------------------------------------------------------------------------------------------
  169. //    public variables & methods  :  OVERRIDING FROM TPOINT
  170. // ----------------------------------------------------------------------------------------------------
  171.     public:
  172. //    Overriding TPoint Methods    .......................................................            
  173.         void IPoint(short p1V, short p1H, short type, Boolean seg,float);
  174.         void Highlight(void);                                                                                        // highlight the point
  175.         void Draw(void);                                                                                            // draw the point
  176.         Boolean IsCornor (void);                                                                                // point IS cornor
  177.         Boolean IsSegment (void);                                                                                // returns seg;
  178.     };
  179.     
  180.  
  181. // *********************************************************************************
  182. //    TInteriorPoint Class            =    Interior point to hold interior data
  183. //        draws differently from TPoint
  184. // *********************************************************************************
  185. class TInteriorPoint : public TSegPoint
  186.     {
  187. // ----------------------------------------------------------------------------------------------------
  188. //    public variables & methods  :  OVERRIDING FROM TPOINT
  189. // ----------------------------------------------------------------------------------------------------
  190.     public:
  191. //    Overriding TPoint Methods    .......................................................            
  192.         void Highlight(void);                                                                                        // highlight the point
  193.         void Draw(void);                                                                                            // draw the point
  194.         Boolean IsInterior (void)                    {return true;}                                        // point IS interior
  195.     };
  196.     
  197. // *********************************************************************************
  198. //    TRow Class                        =    List of Pointers to Segment Points
  199. // *********************************************************************************
  200. class TRow : public TList
  201.     {
  202.     protected:
  203.         Point    snap;
  204. // ----------------------------------------------------------------------------------------------------
  205. //    public variables & methods 
  206. // ----------------------------------------------------------------------------------------------------
  207.     public:
  208.         void         IRow (TPoint *, TPoint *);                                                            // init the row
  209.         pascal void Each (pascal void (*DoToItem)(TObject *, void *), void*DoToItem_StaticLink);
  210.         short     SearchPoint (Point *);                                                                    // search for a point
  211.         short     SearchSection (Point *);                                                                // searchs line segs for point
  212.         Boolean PointOnLine (Point, Point, Point  *);                                                // is point on this line?
  213.         void         SnaptoSection (Point *);
  214.     
  215.         TGridPoint *    AddPointAt (short, Point,float);                                            // add a point to row
  216.         extended        GetLength (TPoint *);                                                            // get length of line
  217.         extended        GetDifferance (short, ArrayIndex, Boolean);                            // get x/y difference
  218.         short            GetNumberSegments (void);                                                    // how many segments
  219.         TPoint *        GetAdjacentSegment (Boolean, TPoint *);                                // return surrounding segments
  220.         short            GetNumBaffle(Boolean);                                                        // return number baffles
  221.         short            GetNumObstacle(void);                                                            // return number baffles
  222.         void                 WriteSegmentData (WallRecord *, TOutput *, short, char *);    // write out the wall data
  223.         void                 WBack (TOutput *, short, char *,long);
  224.         void                 WForward (TOutput *, short, char *,long);
  225.         void                 FixHold(void);
  226.         void                 RememberRow (void);
  227.         void                 RetrieveAndFixRow(void);
  228.  
  229.         virtual short GetSide(void)            {return cNotOnBoundry;}                        // return this boundry
  230.     };
  231.     
  232. // *********************************************************************************
  233. //    TSegmentList Class            =    List of Pointers to Segment Points
  234. // *********************************************************************************
  235. class TBoundry : public TRow
  236.     {
  237.     protected:
  238.         short     fSide;                                                                                        // the boundry
  239. // ----------------------------------------------------------------------------------------------------
  240. //    public variables & methods 
  241. // ----------------------------------------------------------------------------------------------------
  242.     public:
  243.         void IRow(TPoint * p1, TPoint * p2, short side);                                    // init the row : override
  244.         short GetSide(void)                            {return fSide;}                                // return this boundry
  245.     };
  246.     
  247. // *********************************************************************************
  248. //    Structure for adding and dragging points
  249. // *********************************************************************************
  250. typedef struct PointInfo
  251.     {
  252.     TRow                *    aboveRow;                                                                        // row above this row
  253.     TRow                *    belowRow;                                                                        // row below this row
  254.     TPoint                *    above;                                                                                // point above
  255.     TPoint                *    below;                                                                                // point below
  256.     TPoint                *    left;                                                                                    // point to the left
  257.     TPoint                *    right;                                                                                // point to the right
  258.     TPoint                *    oPt;                                                                                    // point up & left
  259.     TPoint                * lrc;                                                                                    // lower right corner
  260.     Boolean                dLeft;                                                                                    // drag draw direction
  261.     Boolean                dRight;                                                                                    // drag draw direction
  262.     Boolean                gridOnly;                                                                                // draw only the grid?
  263.     Boolean                noGrid;                                                                                    // draw only boundries.
  264.     short                 boundry;                                                                                // boundy its on
  265.     short                row;                                                                                        // row point is in
  266.     short                column;                                                                                // column point is in
  267.     float                    magnify;                                                                                // magnification factor
  268.     } PointInfo;
  269.  
  270. // *********************************************************************************
  271. //    TBaffle Class            =    the Baffles
  272. // *********************************************************************************
  273. class TBaffle : public TObject
  274.     {
  275.     protected:
  276.         TPoint    *    fPt1;                                                                                        // cornors of obstacle
  277.         TPoint    *    fPt2;
  278.         short    fDirection;
  279.  
  280.     public:
  281.         void IBaffle(PointInfo *, short);
  282.         void BaffleRelease(void);
  283.         void BaffleSet(void);
  284.  
  285. //    Overriding MacApp Methods    .......................................................            
  286.         void Draw(void);                                                                                        // draws the baffle
  287.         pascal void Free(void);
  288.     };
  289.     
  290. // *********************************************************************************
  291. //    TObstacle Class            =    the Obstacles
  292. // *********************************************************************************
  293. class TObstacle : public TObject
  294.     {
  295.     protected:
  296.         TPoint    *    fUpLeft;                                                                                    // cornors of obstacle
  297.         TPoint    *    fUpRight;
  298.         TPoint    *    fLwLeft;
  299.         TPoint    *    fLwRight;
  300.         
  301.     public:
  302.         void IObstacle(PointInfo *);                                                                        // initialize obstacle list
  303.         void SetCorners(PointInfo *);
  304.  
  305. //    Overriding MacApp Methods    .......................................................            
  306.         void Draw (void);                                                                                        // draws the obstacle
  307.         void ReleaseObstacle(void);
  308.         void SetObstacle(void);
  309.         pascal void Free(void);
  310.     };
  311.     
  312. // *********************************************************************************
  313. //    TPointMatrix Class            =    List of Rows of Points
  314. //        This is the OverSeer point list
  315. // *********************************************************************************
  316. class TPointMatrix : public TList
  317.     {
  318. // ----------------------------------------------------------------------------------------------------
  319. //    protected variables & methods 
  320. // ----------------------------------------------------------------------------------------------------
  321.     protected:
  322.         TView            *     fGeomView;
  323.         TDocument    *    fDocument;
  324.         TList            *    aColumn;                                                                                // a column
  325.         Boolean            fShown;                                                                                    // is grid on screen
  326.         Boolean            fFineGrid;
  327.         short            fRow, fColumn;                                                                            // current row & column
  328.         short            flocation;                                                                                    // index of the point
  329.         short            fOBoundry;                                                                                // opposite boundry
  330. // ----------------------------------------------------------------------------------------------------
  331. //    public variables & methods 
  332. // ----------------------------------------------------------------------------------------------------
  333.     public:
  334.         short            fBoundry;                                                                                    // current boundry
  335.         TBoundry        *    fTop;
  336.         TBoundry        *     fBottom;
  337.         TBoundry        *     fLeft;
  338.         TBoundry        *     fRight;
  339.         
  340.         Boolean     IPointMatrix(TDocument *, TView *);
  341.         void             InitCorners(void);
  342.         pascal void Free(void);
  343.         TPoint    *     GetCurrent(void);                                                                            // current row / column
  344.         short          SetCurrent(TPoint * );                                                                    // set new current row/column
  345.         TRow    *     GetCurrentBoundry(void);                                                                // return current boundry
  346.         TPoint    *     GetOpposite(TBoundry *, short, short);                                        // point on opposite boundry
  347.         short        GetRow(void)                        {return fRow;}                                    // returns current row
  348.         short        GetColumn(void)                    {return fColumn;}                                // returns current row
  349.         short        GetTColumn(void);                                                                        // how many columns?
  350.         short        GetNumBaffle(Boolean);                                                                // return number baffles
  351.         short        GetNumObstacle(void);                                                                    // return number baffles
  352.         short        SetCornors(TPoint * , PointInfo *);                                                // set surrounding points
  353.         Boolean        IsShown(void)                        {return fShown;}                                // is grid displayed?
  354.         void            SetFineGrid(Boolean value)    {fFineGrid = value;}                            // fine grid on/off
  355.         Boolean        GetFineGrid(void)                    {return fFineGrid;}                            // fine grid on/off
  356.         
  357. //    Drawing methods    .......................................................    
  358.         void DoDraw(void);                                                                                        // draw all
  359.         void DoDrawSegment(void);                                                                            // draw a segment
  360.         void DoDrawGrid(void);                                                                                // draw the grid only
  361.         void DoHighlight(void);                                                                                    // highlight segment or point
  362.         void DrawHold(Boolean);
  363.         void ShowFineGrid(void);                                                                                // draw the fine grid
  364.         void CalculateFinePt(lineSlope *, short, extended, Point *);
  365.  
  366. //    boundry methods    .......................................................    
  367.         TPoint *         FindBoundryPoint(Point * );                                                        // find a point on boundry
  368.         short             FindBoundry(TPoint * );                                                            // which boundry is point on
  369.         TPoint *         FindSection(Point * );                                                                // find line section point is on
  370.         TSegPoint *    FindSegment(TPoint * ,TRow * );                                                // find line segment point is on
  371.         TPoint *         FindCell(Point *, PointInfo *);
  372.         void              DefineSearchRegion(PointInfo *, RgnHandle, short,short,short,short);
  373.         short            FindLine (Point *, PointInfo *);
  374.  
  375.         void TBBoundryDo(pascal void (*DoToItem)(TObject *, void *), void *);        // do to top / bottom boundry
  376.         void RLBoundryDo(pascal void (*DoToItem)(TObject *, void *), void *);        // do to left/ right boundry
  377.  
  378.         void  SelectSegment(TPoint * , TRow * , Boolean );                                        // select all sections in a segment
  379.         void  SetSegment(TPoint * , TRow * , short );                                                // change segment type
  380.  
  381. //    grid & boundry methods ... work when grid is present on entire mesh
  382.         TPoint *     FindPoint(Point * );                                                                        // find any pt (boundry / grid)
  383.         short         SearchColumnSection(short , Point *, PointInfo *);                        // search a column for section
  384.         TPoint *    SearchColumnPoint(short , Point * );                                            // search a column for point
  385.  
  386.         pascal void Each(pascal void (*DoToItem)(TObject *, void *), void * );        // do to each point
  387.         void            OneRowDo(pascal void (*DoToItem)(TObject *, void *), void *);    // do to a row
  388.         void             OneColumnDo(pascal void (*DoToItem)(TObject *, void *), void * ); // do to a column
  389.  
  390. //    Add segment methods    .......................................................    
  391.         Boolean            AddAt(TPoint * , TPoint * , short , short );                                // add a new point
  392.         TGPoint     *    GetOpposite(Point * , PointInfo * , PointInfo * );                        // calculate opposite point
  393.  
  394. //    Grid creation / manipulation methods    .......................................................            
  395.         Point            CalculateLocation(lineSlope *, extended, extended);
  396.         TRow    *        CreateGridRow(short);
  397.         TRow    *         CreateGridColumn(short);
  398.         void                RememberColumn(void);
  399.         void                 FixHold(void);
  400.         void                FixHoldColumn(short);
  401.         void                 RetrieveAndFix2Hold(void);
  402.         void                 RetrieveAndFixColumn(short);
  403.         void                 MovePoints(Point,extended);
  404.         void                 MoveRow(Point,extended);
  405.         void                 MoveColumn(Point,extended);
  406.         
  407. //    Grid deletion  methods    .......................................................            
  408.         short            ObsBaffInLine(TBoundry *);
  409.         TList    *         DeleteCurrent(TRow *);
  410.         TPoint    *        AddLine(TList *,TRow *,short,short);
  411.  
  412. //    File read / write methods    .......................................................            
  413.         void                 WriteGrid(TOutput *, short, short);
  414.         void                 WriteBaffles(Boolean, TOutput *, short);
  415.         void                 WriteObstacles(TOutput *, short);
  416.         short             GetColumnLength(short);
  417.         void                 ReadGrid(short, char *);
  418.         Boolean            ReadSegment(short, short, char *, short);
  419.         void                 ReadData(WallRecord *, short, char *);
  420.         Boolean            FillGrid(short, short);
  421.         void                 ReadObstructions(short, char *);
  422.     };
  423.  
  424.